<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v-bind实战案例</title>
  <style>
    .active {
      color: #bfa;
    }

    .line {
      color: pink;
    }

    .title {
      font-size: 40px;
    }
  </style>
</head>

<body>
  <div id="root">
    <!-- 方法一：放在这里 -->
    <!-- <h2 class="title" :class="{active:isActive,line:isLine}">{{message}}</h2> -->
    <!-- 方法二： -->
    <h2 class="title" :class="getClasses()">{{message}}</h2>
    <!-- 真实调用函数的时候，都要加上(),下面这里是被省略掉了 -->
    <button @click="btnClick">切换颜色</button>
  </div>
  <script src="../practice_project/js/vue.js"></script>
  <script>
    const root = new Vue({
      el: '#root',
      data: {
        message: 'v-bind实战案例',
        isActive: true,
        isLine: false
      },
      methods: {
        // 这样看起来更加舒服
        getClasses: function () {
          return {
            // 这里获取变量的时候记得加上this
            active: this.isActive,
            line: this.isLine
          }
        },
        btnClick() {
          this.isActive = !this.isActive;
          this.isLine = !this.isLine;
        }
      }
    })
  </script>
</body>

</html>